<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>
Welcome to QQ's Website
</title>
<LINK href="style.css" rel=stylesheet>
<META http-equiv=Content-Type
content="text/html; charset=utf-8">
<style type="text/css">
body,td,th {
	font-family: "Times New Roman", Times, serif;
}
a {
	font-family: "Times New Roman", Times, serif;
}
</style>
</head>
<body bottomMargin=0 leftMargin=0
topMargin=0 rightMargin=0>
<TABLE width="1024" height="768" border=0 cellSpacing=0
cellPadding=0 align=center>
<TR HEIGHT="100">
<TD Align=center colspan=5>
<%@include file="top.jsp"%>
</TD>
</TR>

<!---Khai báo khoảng phân cách--->
<TR HEIGHT="2">
<TD colspan=5 bgcolor=white></TD>
</TR>
<TR HEIGHT=100%>
<TD vAlign="top" width="150">
<%@include file="left.jsp"%>
</TD>

<!---Khai báo khoảng phân cách--->
<TD bgcolor=white width="2"></TD>
<TD vAlign=top width="720">

<%
	Class.forName("com.mysql.jdbc.Driver");
	Connection con = null;
	Statement smt = null;
	ResultSet rst = null;
	int i = 0;
	try {
		String username = "root";
		String password = "Vietyeutam1112";
		String url = "jdbc:mysql://127.0.0.1:3306/banhang";
		String provider = request.getParameter("provider");
		System.out.println(provider);
		
		con = DriverManager.getConnection(url, username, password);
		System.out.println("Da ket noi CSDL");
		smt = con.createStatement();
		rst = smt.executeQuery("select * from product where provider='"+provider+"'");
		out.print("<table width="+"720"+" height="+"100%"+" border="+"0"+">");
		while (rst.next()) {
			if(i%3 == 0) out.print("<tr>");
			out.print("<td width="+"240"+" align="+"center"+">"+"<img src="+rst.getString(5)+" width=200><br>"+rst.getString(2)+"<br><font color=red>"+rst.getString(4)+" đ</font>"+"<br><a href="+"productdetail.jsp?ID="+rst.getString(1)+">Chi tiết</a></td>");
			i++;
			if(i%3 == 0) out.print("</tr>");
		}
		out.print("</table>");
		con.close();
		System.out.println("Dong ket noi");
	}
	catch (Exception e) {
		System.out.println("KHONG KET NOI DUOC");
	}
%>

</TD>
<!---Khai báo khoảng phân cách--->
<TD bgcolor=white width="2"></TD>
<TD vAlign=top width="150">
<%@include file="right.jsp"%>
</TD>
</TR>
<!---Khai báo khoảng phân cách--->
<TR HEIGHT="2">
<TD colspan=5 bgcolor=white></TD>
</TR>
<TR HEIGHT="50">
<TD colspan=5 align=center>
<%@include file="bottom.jsp"%>
</TD>
</TR>
</TABLE>
</body>
</html>